//
//  ForthViewController.m
//  B段项目
//
//  Created by 昶博 on 15/9/23.
//  Copyright (c) 2015年 昶博. All rights reserved.
//

#import "ForthViewController.h"
#import "ForthView.h"
#import "DetailViewController.h"
#import "AFNetworking.h"
#import "NextViewController.h"
#import <UIImageView+WebCache.h>
#import "MoreViewController.h"
@interface ForthViewController ()
@property(nonatomic ,strong)ForthView *radio;
@end

@implementation ForthViewController
-(void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0.067 green:0.694 blue:0.651 alpha:1.000];
    self.title = @"麦奇电台";
    self.navigationController.navigationBar.titleTextAttributes = @{@"Font":[UIFont fontWithName:nil size:20], @"TextColor":[UIColor colorWithRed:0.804 green:0.671 blue:0.439 alpha:1.000]};
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"更多" style:UIBarButtonItemStylePlain target:self action:@selector(backClicked)];

    SelfTabBar.hidden = NO;
    
    
       
}

// 更多button点击事件
-(void)backClicked
{
    MoreViewController *more = [[MoreViewController alloc]init];
    [self.navigationController pushViewController:more animated:YES];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.radio = [[ForthView alloc]initWithFrame:self.view.frame];
     
    [self.view addSubview:self.radio];
    [self AddSubView];
    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    [center addObserver:self selector:@selector(push:) name:@"push" object:nil];
  
    NSNotificationCenter *center1 = [NSNotificationCenter defaultCenter];
    [center1 addObserver:self selector:@selector(push1:) name:@"change" object:nil];

   
}

-(void)push:(NSNotification *)noti
{
    NextViewController *next = [[NextViewController alloc]init];
    [self.navigationController pushViewController:next animated:YES];
    
   
        next.model = noti.object;
  
    
    
}
-(void)AddSubView
{
    
    self.belowView = [[BelowView alloc]initWithFrame:CGRectMake(0, ScreenHeight-150*h, ScreenWidth, 200*h)];
    self.belowView.backgroundColor =[UIColor colorWithRed:0.027 green:0.212 blue:0.278 alpha:0.5];
    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    [center addObserver:self selector:@selector(chageImage:) name:@"changeImage" object:nil];
    NSNotificationCenter *center1 = [NSNotificationCenter defaultCenter];
    [center1 addObserver:self selector:@selector(changeLabel:) name:@"changeLabel" object:nil];
    
    
    [self.view addSubview:self.belowView];
    

    
}
-(void)push1:(NSNotification *)cation
{
    
    DetailViewController *deta = [[DetailViewController alloc]init];
    
    deta.model = cation.object;
    [self presentViewController:deta animated:YES completion:^{
        
        
        
    }];
}

-(void)chageImage:(NSNotification *)cation
{
     self.model = cation.object;
    [self.belowView.imageView sd_setImageWithURL:[NSURL URLWithString:self.model.album_imgurl] placeholderImage:[UIImage imageNamed:@"44"]];
 }
-(void)changeLabel:(NSNotification *)cation
{
    self.model = cation.object;
    self.belowView.titleLabel.text = self.model.program_title;
    self.belowView.label.text = self.model.program_live_time;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
